<template>
	<view class="container">
		<view class="hg-30"></view>
		<!-- 列表-->
		<view class="list">
			<view @click="handleOpenPage(0)">
				<view>
					<image src="http://images.linglinggong.net/icon2/04.png" mode="aspectFill" ></image>
					<view>
						<view>雇人干活</view>
						<text>把您的要求发布出来</text>
					</view>
				</view>
				<image src="http://images.linglinggong.net/icon1/17.png" mode="aspectFill"></image>
			</view>
			<view @click="handleOpenPage(1)">
				<view>
					<image src="http://images.linglinggong.net/icon2/09.png" mode="aspectFill" ></image>
					<view>
						<view >我发布的零工</view>
						<text>查看我发布的零工</text>
					</view>
				</view>
				<image src="http://images.linglinggong.net/icon1/17.png" mode="aspectFill"></image>
			</view>
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				userInfo: { user: {}, params: {} },//当前用户信息
				hasFlag: true,//是否加载完成
				requestObj: {
					pageNum: 0,
					pageSize: 10,
					userId: '',
					status: '',
					userId: '',
					isAsc: 'desc',
					orderByColumn:'createTime',
				},
			}
		},
		props: {
			// 每次页面出现时，isShow变化
			isShowBoss: {
				type: Number,
				default: 0
			},
		},
		watch: {
			isShowBoss: function (newVal) {
				this.userInfo = uni.getStorageSync('userInfo')
			}
		},
		methods: {
			// 打开内页面
			async handleOpenPage (page) {
				if(page == 0) {
				//	console.log('要实名认证',this.userInfo,this.userInfo.idCardStatus,this.userInfo.user.authSwitch)
						var index=0
					if(uni.getStorageSync("userd")=="5"){
						uni.setStorageSync("userd","5")
						//console.log('获取我的零工',this.hasFlag,this.handleIsStop)
						if (!this.hasFlag) return // 说明已经没有更多啦
						++this.requestObj.pageNum
						
						this.requestObj.userId = this.userInfo.userId
						// console.log('获取我的零工 参数this.requestObj',this.requestObj)
						let res = await this.$fetch(this.$api.task_list, this.requestObj, 'POST')
						if (res.code) return uni.showToast({ title: res.msg, icon: 'none' })
						console.log(res.rows)
					
						for(var i=0;i<res.rows.length;i++){
							if(res.rows[i].status=="5"){}
							index=index+1
							}
						
					}
					
					
					
					// 要实名认证
					if(this.userInfo.idCardStatus !=2 &&index>=1) {
					//	console.log("1111111111111")
						// uni.showModal({
						// 	title: '尊敬的找零工用户', 
						// 	content: '您的任务已达上限，请先去实名后发布零工!',
						// 	cancelText: '去实名',
						// 	confirmText: '取消',
						// 	success: (res) => {
						// 		if (res.cancel) {  
						// 			uni.navigateTo({ url: '/pages/real-name/real-name' })
								
						// 		}else {
						// 				console.log('取消')
						// 		} 
						// 	}
						// })
						
						
					}else {
						// #ifdef MP-WEIXIN || MP-TOUTIAO
						uni.navigateTo({
							url: '/pages/app-employer/send-job/send-job'
						})
						// #endif
						// #ifdef MP-ALIPAY
						uni.reLaunch({
							url: '/pages/app-employer/send-job/send-job'
						})
						// #endif
					}
				}else {
					//uni.navigateTo({ url: '/pages/my-job/boss-my-job' })
					uni.reLaunch({ url: '/pages/my-job/boss-my-job-new' })
				}
			},
		},
		mounted() {
			uni.setNavigationBarTitle({ title: '发布' })
		}
	}
</script>

<style lang="less" scoped> 
.container {
	// border: 1px solid #000000;
	overflow: hidden;
	position: relative;
	
	& > .list {
		// background-color: #FFFFFF;
		& > view {
			padding: 28rpx 30rpx;
			position: relative;
			display: flex;
			align-items: center;
			justify-content: space-between;
			letter-spacing: 0;
			& > view {
				display: flex;
				align-items: center;
				& > image {
					margin-right: 30rpx;
					width: 62rpx;
					height: 64rpx;
				}
				& > view {
					margin: 0;
					display: flex;
					flex-direction: column;
					& > view {
						line-height: 40rpx;
						margin-bottom: 10rpx;
					}
					& > text {
						line-height: 34rpx;
						font-size: 12px;
						color: rgba(64,33,16,0.50);
					}
				}
			}
			& > image {
				width: 16rpx;
				height: 26rpx;
			}
			&::after {
				content: "";
				position: absolute;
				bottom: 0rpx;
				width: 720rpx;
				height: 2rpx;
				background: #F2F2F2;
			}
		}
	}
}
</style>
